<!-- 推送明细查询 -->
<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryRef" :inline="true">
            <el-form-item label="权限名称" prop="name">
                <el-input
                    v-model="queryParams.idenno"
                    placeholder="请输入权限名称"
                    clearable
                    @keyup.enter="handleQuery"
                ></el-input>
            </el-form-item>
        </el-form>
        <!-- button area -->
        <el-row :gutter="20" class="mb8">
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    icon="Search"
                    @click="handleQuery"
                    >查询</el-button
                >
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" plain icon="Plus" @click="handleAdd"
                    >添加</el-button
                >
            </el-col>
            <el-col :span="1.5">
                <el-button
                    type="warning"
                    plain
                    icon="Close"
                    @click="handleClose"
                    >关闭</el-button
                >
            </el-col>
        </el-row>
        <el-table :data="tableData" :loading="loading">
            <el-table-column
                label="实体编码"
                align="center"
                prop="id"
            ></el-table-column>
            <el-table-column label="实体类型" align="center" prop="type">
                <template #default="scope">
                    <dict-tag
                        :options="auth_entity_type"
                        :value="scope.row.type"
                    /> </template
            ></el-table-column>
            <el-table-column
                label="实体名称"
                align="center"
                prop="name"
            ></el-table-column>
            <el-table-column label="状态" align="center" prop="state">
                <template #default="scope">
                    <el-switch
                        v-model="scope.row.state"
                        active-value="1"
                        inactive-value="0"
                        @change="handleStatusChange(scope.row)"
                    ></el-switch> </template
            ></el-table-column>
            <el-table-column
                label="创建时间"
                align="center"
                prop="createTime"
            ></el-table-column>
        </el-table>
        <select-auth
            ref="selectRef"
            :groupId="queryParams.groupId"
            @ok="handleQuery"
        />
    </div>
</template>

<script setup name="GroupAuth">
import { reactive, ref, toRefs, getCurrentInstance } from 'vue'
import { listByGroupId } from '@/api/system/auth'
import { useRoute } from 'vue-router'
import selectAuth from './selectAuth'
const route = useRoute()
const { proxy } = getCurrentInstance()
const { sys_normal_disable, auth_entity_type } = proxy.useDict(
    'sys_normal_disable',
    'auth_entity_type'
)
const data = reactive({
    tableData: [],
    queryParams: { groupId: route.params.groupId, name: '' }
})
const { queryParams, tableData } = toRefs(data)
const loading = ref(false)
function handleQuery() {}
function getGroupAuthList() {}
function handleAdd() {
    proxy.$refs['selectRef'].show()
}
// 返回按钮
function handleClose() {
    const obj = { path: '/system/authgroup' }
    proxy.$tab.closeOpenPage(obj)
}
;(() => {
    const groupId = route.params && route.params.groupId
    if (groupId) {
        loading.value = true
        listByGroupId(groupId).then((res) => {
            tableData.value = res.data
            loading.value = false
        })
    }
})()
</script>
<style scoped></style>
